package com.holyant.report.dto;

import com.ruoyi.common.core.annotation.Excel;
import com.ruoyi.common.core.domain.BaseDto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;
import java.math.BigInteger;

/**
 * 库存渠道比例dto
 * 
 * @author fkmalls
 * @date 2022-03-21
 */
@Data
@ApiModel("库存渠道比例")
public class RptInventoryChannelProportionDto extends BaseDto {

    private static final long serialVersionUID = 1L;

    /** 品牌ID */
    @Excel(name = "品牌ID")
    @ApiModelProperty(value = "品牌ID")
    private Long brandId;
    /** 品牌code */
    @Excel(name = "品牌code")
    @ApiModelProperty(value = "品牌code")
    private String brandCode;
    /** 品牌名称 */
    @Excel(name = "品牌名称")
    @ApiModelProperty(value = "品牌名称")
    private String brandName;
    /** 渠道id */
    @Excel(name = "渠道id")
    @ApiModelProperty(value = "状态")
    private Integer status;
    /** 报关类型 10=国贸20=跨境 */
    @Excel(name = "报关类型 10=国贸20=跨境")
    @ApiModelProperty(value = "报关类型 10=国贸20=跨境")
    private Integer customsType;
    /** pop渠道百分比 */
    @Excel(name = "pop渠道百分比")
    @ApiModelProperty(value = "pop渠道百分比")
    private BigDecimal popPercentage;
    /** c2p渠道百分比 */
    @Excel(name = "c2p渠道百分比")
    @ApiModelProperty(value = "c2p渠道百分比")
    private BigDecimal c2pPercentage;
    /** b2b渠道百分比 */
    @Excel(name = "b2b渠道百分比")
    @ApiModelProperty(value = "b2b渠道百分比")
    private BigDecimal b2bPercentage;
    /** ka渠道百分比 */
    @Excel(name = "ka渠道百分比")
    @ApiModelProperty(value = "ka渠道百分比")
    private BigDecimal kaPercentage;

    /** 当前品牌库存总数 */
    private BigDecimal totalInventory;


    private BigInteger popTotalInventory;
    private BigInteger c2pTotalInventory;
    private BigInteger b2bTotalInventory;
    private BigInteger kaTotalInventory;


    public BigDecimal getTotalInventory() {
        if (null != totalInventory &&  totalInventory.compareTo(new BigDecimal(0)) != 0){
            return totalInventory.setScale(0,BigDecimal.ROUND_HALF_UP);
        }
        return totalInventory;
    }

    public BigInteger getPopTotalInventory() {
        if (null != totalInventory && totalInventory.compareTo(new BigDecimal(0)) != 0 && popPercentage != null){
            BigDecimal bigDecimal = popPercentage.divide(new BigDecimal(100));
            BigDecimal multiply = totalInventory.multiply(bigDecimal).setScale(0, BigDecimal.ROUND_HALF_UP);
            return multiply.stripTrailingZeros().toBigInteger();
        }
        return null;
    }
    public BigInteger getC2pTotalInventory() {
        if (null !=totalInventory && totalInventory.compareTo(new BigDecimal(0)) != 0 && c2pPercentage != null){
            BigDecimal bigDecimal = c2pPercentage.divide(new BigDecimal(100));
            BigDecimal multiply = totalInventory.multiply(bigDecimal).setScale(0, BigDecimal.ROUND_HALF_UP);
            return multiply.stripTrailingZeros().toBigInteger();
        }
        return null;
    }
    public BigInteger getB2bTotalInventory() {
        if (null !=totalInventory && totalInventory.compareTo(new BigDecimal(0)) != 0 && b2bPercentage != null){
            BigDecimal bigDecimal = b2bPercentage.divide(new BigDecimal(100));
            BigDecimal multiply = totalInventory.multiply(bigDecimal).setScale(0, BigDecimal.ROUND_HALF_UP);
            return multiply.stripTrailingZeros().toBigInteger();
        }
        return null;
    }
    public BigInteger getKaTotalInventory() {
        if (null !=totalInventory && totalInventory.compareTo(new BigDecimal(0)) != 0 && kaPercentage != null){
            BigDecimal bigDecimal = kaPercentage.divide(new BigDecimal(100));
            BigDecimal multiply = totalInventory.multiply(bigDecimal).setScale(0, BigDecimal.ROUND_HALF_UP);
            return multiply.stripTrailingZeros().toBigInteger();
        }
        return null;
    }

}
